package cn.me.implement.threadpool.reject;

import cn.me.implement.threadpool.JaneThreadPool;

/**
 * 线程池无法执行任务时的拒绝策略
 */
public interface RejectPolicy {

    /**
     * 线程池拒绝执行任务
     *
     * @param rejectTask 被拒绝的任务
     * @param threadPool 拒绝执行任务的线程池
     */
    void reject(Runnable rejectTask, JaneThreadPool threadPool);

    RejectPolicy THROW_REJECT_POLICY = new ThrowRejectPolicy();
    RejectPolicy DISCARD_OLDEST_REJECT_POLICY = new DiscardOldestRejectPolicy();
}
